﻿@model SelectModifyFieldViewModel

<div class="select-field-page account-page">
    <div class="select-bind-card mdl-card mdl-shadow--2dp">
        <img class="head-logo" src="https://res.cngal.org/_content/CnGalWebSite.Shared/images/head_logo_6th.png">
        <div class="mdl-card__title">
            <h2 class="mdl-card__title-text">编辑账号信息</h2>
        </div>

        @if (string.IsNullOrWhiteSpace(Model.SecondCode))
        {

            <div class="mdl-card__supporting-text text-center">
                为了确保你的账号安全，在编辑之前需要进行二次身份验证
            </div>
            <partial name="_ValidationSummary" />

            <div class="mdl-card__supporting-text">


                <div class="action">
                    <form asp-route="SelectModifyField" onsubmit="return callGeetest()">
                        <input type="hidden" asp-for="ReturnUrl" />

                        <!--极验-->
                        <input id="geetestResult-validate" type="hidden" asp-for="VerifyResult.Validate" />
                        <input id="geetestResult-seccode" type="hidden" asp-for="VerifyResult.Seccode" />
                        <input id="geetestResult-challenge" type="hidden" asp-for="VerifyResult.Challenge" />

                        <div id="captcha-box"></div>
                        <button class="d-none" id="geetestCode-submit-button" type="submit"></button>
                        <!--极验-->
                        <button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored">验证</button>
                    </form>
                    <form asp-route="SelectModifyField">
                        <button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent" name="button" value="cancel">取消</button>
                    </form>
                </div>

            </div>
        }
        else
        {
            <div class="mdl-card__supporting-text text-center">
                修改账号绑定的某些信息后，可能需要重新进行身份验证
            </div>
        }
    </div>
    @foreach (var item in Model.BindInfor.AccountFields)
    {
        <div class="mdl-card mdl-shadow--2dp">
            <div class="mdl-card__supporting-text bind-card">
                <div class="name-bind">
                    <div class="key">
                        <i class="@item.Icon info--text"></i>
                        @item.Type.GetDisplayName()
                    </div>
                    @if (item.Actions.Count > 1 || item.Type == SelectModifyFieldType.Email)
                    {
                        <div class="value success--text">
                            <i class="mdi mdi-check-circle"></i>
                            已绑定
                        </div>
                    }
                    else if (item.Type != SelectModifyFieldType.Password)
                    {
                        <div class="value warning--text">
                            <i class="mdi mdi-clock-outline"></i>
                            未绑定
                        </div>
                    }
                </div>
                @if (string.IsNullOrWhiteSpace(Model.SecondCode) == false)
                {
                    <div class="action-bind">
                        @foreach (var infor in item.Actions)
                        {
                            <a asp-controller="Account" asp-action="@infor.Value" asp-route-returnUrl="@Model.ReturnUrl" asp-route-type="@item.Type" asp-route-secondCode="@Model.SecondCode">@infor.Key.GetDisplayName()</a>
                        }
                    </div>
                }

            </div>
        </div>
    }
    @foreach (var item in Model.BindInfor.ExternalFields)
    {
        <div class="mdl-card mdl-shadow--2dp">
            <div class="mdl-card__supporting-text bind-card">
                <div class="name-bind">
                    <div class="key">
                        <i class="@item.Icon  info--text"></i>
                        @item.DisplayName
                    </div>
                    @if (item.Actions.Count > 1)
                    {
                        <div class="value success--text">
                            <i class="mdi mdi-check-circle"></i>
                            已绑定
                        </div>
                    }
                    else
                    {
                        <div class="value warning--text">
                            <i class="mdi mdi-clock-outline"></i>
                            未绑定
                        </div>
                    }
                </div>
                @if (string.IsNullOrWhiteSpace(Model.SecondCode) == false)
                {
                    <div class="action-bind">
                        @foreach (var infor in item.Actions)
                        {
                            @if (string.IsNullOrWhiteSpace(infor.Value))
                            {
                                <a asp-controller="External"
                                   asp-action="Challenge"
                                   asp-route-scheme="@item.AuthenticationScheme"
                                   asp-route-returnUrl="@Model.ReturnUrl">
                                    @infor.Key.GetDisplayName()
                                </a>
                            }
                            else
                            {
                                <a asp-controller="Account" asp-action="@infor.Value" asp-route-returnUrl="@Model.ReturnUrl" asp-route-provider="@item.DisplayName" asp-route-secondCode="@Model.SecondCode">@infor.Key.GetDisplayName()</a>
                            }
                        }
                    </div>
                }

            </div>
        </div>
    }
</div>
